package com.hao.tool.extra.cloud.module.youtu.fac;

import com.hao.tool.common.util.JsonKitUtil;
import com.hao.tool.extra.cloud.module.youtu.entity.OcrResult;

import java.util.HashMap;
import java.util.Map;

/**
 * description
 *
 * @author RuiHaoZ on CMHK.gz
 * @date 2020-08-26 14:19
 */
public class YouTuUtil {

    public static <T> T transfer(String rep, Class<T> t) {
        OcrResult driverResult = JsonKitUtil.getObject(rep, OcrResult.class);
        Map<String, String> params = new HashMap<>();
        for (OcrResult.ItemDTO item : driverResult.getItems()) {
            params.put(item.getItem(), item.getItemString());
        }
        String b = JsonKitUtil.getString(params);
        T dto = JsonKitUtil.getObject(b, t);
        return dto;
    }
}
